using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace WindowsGame1
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        bool visivel;

        Texture2D Tr_base, Tr_bforca, Tr_campoforca;

        Vector2 posicaoBase, posicaobforca, posicaocampoforca;

        MouseState mouse_atual, mouse_anterior;
        KeyboardState teclado_atual, teclado_anterior;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            base.Initialize();
        }

        
        protected override void LoadContent()
        {
           
            spriteBatch = new SpriteBatch(GraphicsDevice);

            Tr_base = Content.Load<Texture2D>("base");
            Tr_bforca = Content.Load<Texture2D>("base de forca");
            Tr_campoforca = Content.Load<Texture2D>("campo de forca");

            posicaoBase = new Vector2(200, 150);
            posicaobforca = new Vector2(500, 200);
            posicaocampoforca = new Vector2(100, 100);

            visivel = true;           
        }

        
        protected override void UnloadContent()
        {
            
        }

       
        protected override void Update(GameTime gameTime)
        {
            mouse_atual = Mouse.GetState();
            teclado_atual = Keyboard.GetState();

            if (teclado_atual.IsKeyDown(Keys.Enter))
            {
                if (visivel)
                {
                    visivel = false;
                }
                else
                {
                    visivel = true;
                }
            }

            if (mouse_atual.LeftButton == ButtonState.Pressed)
            {
                if (mouse_atual.X == posicaobforca.X)
                {
                    if (mouse_atual.Y == posicaobforca.Y)
                    {
                        if (visivel)
                        {
                            visivel = false;
                        }
                        else
                        {
                            visivel = true;
                        }
                        
                    }
                } 
                
            }

            mouse_anterior = mouse_atual;
            teclado_anterior = teclado_atual;

            base.Update(gameTime);
        }


        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();

            spriteBatch.Draw(Tr_base, new Rectangle((int)posicaoBase.X, (int)posicaoBase.Y, 102, 108), Color.White);
            spriteBatch.Draw(Tr_bforca, new Rectangle((int)posicaobforca.X, (int)posicaobforca.Y, 61, 60), Color.White);
            
            if (visivel)
            {
                spriteBatch.Draw(Tr_campoforca, new Rectangle((int)posicaocampoforca.X, (int)posicaocampoforca.Y, 202, 192), Color.White);
            }
            
            
            spriteBatch.End();

            base.Draw(gameTime);
        }       
    }
}
